package cn.zhy.basic.config;

import cn.zhy.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                //登录：放行到登录页面的请求【/login】  和  登录请求【/login/account】
                .excludePathPatterns("/login/**")
                //注册：放行用户注册：/user/register/**
                .excludePathPatterns("/user/register/*")
                //注册：放行店铺入驻
                .excludePathPatterns("/shop/settlement")
                //放行文件上传接口
                .excludePathPatterns("/fastDfs/**")
                //放行验证码
                .excludePathPatterns("/verifyCode/**")
                //放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
    }
}